package com.cubeofnine.sugar.service.element;

import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class Contacts implements KvmSerializable {
	private List<Contact> contacts = new Vector<Contact>();

	public Contacts() {
		super();
	}

	public Contacts(List<Contact> contacts) {
		super();
		this.contacts = contacts;
	}

	public Contacts(SoapObject obj) {
		super();
		this.contacts = (Vector<Contact>) obj.getProperty("contacts");
	}

	public Object getProperty(int index) {
		Object object = null;

		switch (index) {
		case 0:
			object = this.contacts;
			break;
		}

		return object;
	}

	public int getPropertyCount() {
		return 1;// Count GloVariable
	}

	public void getPropertyInfo(int index, Hashtable arg1,
			PropertyInfo propertyInfo) {
		switch (index) {
		case 0:
			propertyInfo.name = "contacts";
			propertyInfo.type = PropertyInfo.VECTOR_CLASS;
			break;
		}
	}

	public void setProperty(int index, Object obj) {
		switch (index) {
		case 0:
			this.contacts = (Vector<Contact>) obj;
			break;
		}
	}

	public List<Contact> getContacts() {
		return contacts;
	}

	public void setContacts(List<Contact> contacts) {
		this.contacts = contacts;
	}

	public void addContact(Contact contact) {
		this.contacts.add(contact);
	}

	@Override
	public String toString() {
		return "Contacts [contacts=" + contacts + "]";
	}

}
